package com.sxran.im.handler;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxran.im.dao.ImGroupMapper;
import com.sxran.im.dao.ImNotificationMapper;
import com.sxran.im.info.ImGroup;
import com.sxran.im.info.ImNotification;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class GetNotificationListCmdHandler extends AbstractCmdHandler<ImNotification>{
    @Resource
    private ImNotificationMapper imNotificationMapper;

    @Override
    public Object doBeanService(ImNotification bean) {
        LambdaQueryWrapper<ImNotification> queryWrapper = new LambdaQueryWrapper<>(bean);
        List<ImNotification> list = imNotificationMapper.selectList(queryWrapper);
        // 扩展字段的使用。
        list.forEach(x -> { x.setExtras(JSONObject.parseObject(x.getSpare())); });
        return list;
    }
}
